package com.dingwei.superiordiary.ui.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.allen.library.SuperButton;
import com.dingwei.superiordiary.R;
import com.dingwei.superiordiary.base.LogisticsBean;
import com.dingwei.superiordiary.bean.MyAddressBean;
import com.dingwei.superiordiary.mvp.presenter.FillInLogisticsNumberPresenter;
import com.dingwei.superiordiary.mvp.view.Contract;
import com.lihao.baselibrary.base.BaseActivity;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created time 2018/1/17.
 * Creator 南柯一梦丶 on
 * Personal signature 余生还长 何必慌张
 * Page description :
 */

public class FillInLogisticsNumberActivity extends BaseActivity implements Contract.FillInLogisticsNumberView {

    FillInLogisticsNumberPresenter fillInLogisticsNumberPresenter = new FillInLogisticsNumberPresenter(this);
    @Bind(R.id.img_back)
    ImageView imgBack;
    @Bind(R.id.tv_title)
    TextView tvTitle;
    @Bind(R.id.tv_right)
    TextView tvRight;
    @Bind(R.id.et_logistics_number)
    EditText etLogisticsNumber;
    @Bind(R.id.et_phone)
    EditText etPhone;
    @Bind(R.id.tv_logistics_company)
    TextView tvLogisticsCompany;
    @Bind(R.id.ll_logistics_company)
    LinearLayout llLogisticsCompany;
    @Bind(R.id.btn_submit)
    SuperButton btnSubmit;
    @Bind(R.id.data_layout)
    LinearLayout dataLayout;


    private String logisticsId = "";
    private String id ="";

    @Override
    protected int getContentViewId() {
        return R.layout.activity_fill_in_logistics_number;
    }

    @Override
    protected void initData() {

    }

    @Override
    protected void initView() {
        tvTitle.setText("填写物流单号");

        id = getIntent().getStringExtra("id");

    }

    @Override
    protected void initListener() {

    }


    @OnClick({R.id.img_back,R.id.ll_logistics_company, R.id.btn_submit})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.img_back:
                finish();
                break;
            case R.id.ll_logistics_company:
                intent.setClass(context,LogisticsActivity.class);
                startActivityForResult(intent,0);
                break;
            case R.id.btn_submit:
                fillInLogisticsNumberPresenter.submit(id,logisticsId,etPhone.getText().toString(),etLogisticsNumber.getText().toString());
                break;
        }
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == 0 && resultCode == RESULT_OK) {
            LogisticsBean.DataBean dataBean = (LogisticsBean.DataBean) data.getSerializableExtra("Logistics_info");
            tvLogisticsCompany.setText(dataBean.shipping_name);
            logisticsId = dataBean.shipping_name;
        }
    }

    @Override
    public void submitSuccess() {
        intent = new Intent(BaseActivity.context,WaitAuditActivity.class);
        intent.putExtra("id",id);
        startActivity(intent);
        finish();
    }
}
